switches= [HW,M68k]
+ syscall.x32= [KNL,x86_64] Enable/disable use of x32 syscalls on
+ an x86_64 kernel where CONFIG_X86_X32 is enabled.
+ Default depends on CONFIG_X86_X32_DISABLED.
+
sysfs.deprecated=0|1 [KNL]
Enable/disable old style sysfs layout for old udev
on older distributions. When this option is enabled
elf32_x86_64 support enabled to compile a kernel with this
option set.
+config X86_X32_DISABLED
+ bool "x32 ABI disabled by default"
+ depends on X86_X32
+ default n
+ help
+ Disable the x32 ABI unless explicitly enabled using the
+ kernel paramter "syscall.x32=y".
+
config COMPAT
def_bool y
depends on IA32_EMULATION || X86_X32
#if __SYSCALL_MASK == ~0
cmpq $__NR_syscall_max, %rax
#else
- andl $__SYSCALL_MASK, %eax
- cmpl $__NR_syscall_max, %eax
+.global system_call_fast_compare
+.global system_call_fast_compare_end
+system_call_fast_compare:
+ cmpq $511, %rax /* x32 syscalls start at 512 */
+ .byte P6_NOP4
+system_call_fast_compare_end:
#endif
ja 1f /* return -ENOSYS (already in pt_regs->ax) */
movq %r10, %rcx
#if __SYSCALL_MASK == ~0
cmpq $__NR_syscall_max, %rax
#else
- andl $__SYSCALL_MASK, %eax
- cmpl $__NR_syscall_max, %eax
+.global system_call_trace_compare
+.global system_call_trace_compare_end
+system_call_trace_compare:
+ cmpq $511, %rax /* x32 syscalls start at 512 */
+ .byte P6_NOP4
+system_call_trace_compare_end:
#endif
ja 1f /* return -ENOSYS (already in pt_regs->ax) */
movq %r10, %rcx /* fixup for C */
END(entry_SYSCALL_64)
+#if __SYSCALL_MASK != ~0
+ /* This replaces the usual comparisons if syscall.x32 is set */
+.global system_call_mask_compare
+.global system_call_mask_compare_end
+system_call_mask_compare:
+ andl $__SYSCALL_MASK, %eax
+ cmpl $__NR_syscall_max, %eax
+system_call_mask_compare_end:
+#endif
+
.macro FORK_LIKE func
ENTRY(stub_\func)
SAVE_EXTRA_REGS 8
#include <linux/linkage.h>
#include <linux/sys.h>
#include <linux/cache.h>
+#include <linux/moduleparam.h>
+#undef MODULE_PARAM_PREFIX
+#define MODULE_PARAM_PREFIX "syscall."
+#include <linux/bug.h>
+#include <linux/init.h>
#include <asm/asm-offsets.h>
#include <asm/syscall.h>
+#include <asm/alternative.h>
#define __SYSCALL_COMMON(nr, sym, compat) __SYSCALL_64(nr, sym, compat)
[0 ... __NR_syscall_max] = &sys_ni_syscall,
#include <asm/syscalls_64.h>
};
+
+#ifdef CONFIG_X86_X32_ABI
+
+/* Maybe enable x32 syscalls */
+
+bool x32_enabled = !IS_ENABLED(CONFIG_X86_X32_DISABLED);
+module_param_named(x32, x32_enabled, bool, 0444);
+
+extern char system_call_fast_compare_end[], system_call_fast_compare[],
+ system_call_trace_compare_end[], system_call_trace_compare[],
+ system_call_mask_compare_end[], system_call_mask_compare[];
+
+static int __init x32_enable(void)
+{
+ BUG_ON(system_call_fast_compare_end - system_call_fast_compare != 10);
+ BUG_ON(system_call_trace_compare_end - system_call_trace_compare != 10);
+ BUG_ON(system_call_mask_compare_end - system_call_mask_compare != 10);
+
+ if (x32_enabled) {
+ text_poke_early(system_call_fast_compare,
+ system_call_mask_compare, 10);
+ text_poke_early(system_call_trace_compare,
+ system_call_mask_compare, 10);
+#ifdef CONFIG_X86_X32_DISABLED
+ pr_info("Enabled x32 syscalls\n");
+#endif
+ }
+#ifndef CONFIG_X86_X32_DISABLED
+ else
+ pr_info("Disabled x32 syscalls\n");
+#endif
+
+ return 0;
+}
+late_initcall(x32_enable);
+
+#endif
#else /* CONFIG_X86_32 */
+#ifdef CONFIG_X86_X32_ABI
+extern bool x32_enabled;
+#else
+#define x32_enabled 0
+#endif
+
/*
* This is used to ensure we don't load something for the wrong architecture.
*/
#define compat_elf_check_arch(x) \
(elf_check_arch_ia32(x) || \
- (IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64))
+ (x32_enabled && (x)->e_machine == EM_X86_64))
#if __USER32_DS != __USER_DS
# error "The following code assumes __USER32_DS == __USER_DS"